package mobidever.mygodutch.activity;

import mobidever.mygodutch.R;
import mobidever.mygodutch.activity.base.ActivityFrame;
import mobidever.mygodutch.adapter.AdapterAppGrid;
import mobidever.mygodutch.controls.SliderItem;
import mobidever.mygodutch.controls.SliderMenu.OnSliderMenuClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

public class ActivityMain extends ActivityFrame implements OnSliderMenuClickListener{

	private GridView gvAppGrid;
	private AdapterAppGrid mAdapterAppGrid;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        AppendMainBody(R.layout.main_body);
        initVariable();
        initView();
        initListener();
        BindData();
        createSlideMenu(R.array.SlideMenuActivityMain);
    }
	
	private void initVariable()
	{
		mAdapterAppGrid = new AdapterAppGrid(this);
	}
	
	private void initView()
	{
		gvAppGrid = (GridView) findViewById(R.id.gvAppGrid);
	}
	
	private void initListener()
	{
		gvAppGrid.setOnItemClickListener(new onAppGridItemClickListener());
	}
	
	private void BindData()
	{
		gvAppGrid.setAdapter(mAdapterAppGrid);
	}

	public void onSliderMenuClick(View pView, SliderItem pSliderItem)
	{
		showMsg(pSliderItem.getItemName());
	}
	private class onAppGridItemClickListener implements OnItemClickListener
    {
    	
		public void onItemClick(AdapterView p_Adapter, View p_View, int p_Position,long arg3) {
			String _MenuName = (String)p_Adapter.getAdapter().getItem(p_Position);
			if(_MenuName.equals(getString(R.string.appGridTextUserManage)))
			{
				openActivity(ActivityUser.class);
				return;
			}
			if(_MenuName.equals(getString(R.string.appGridTextAccountBookManage)))
			{
				openActivity(ActivityAccountBook.class);
				return;
			}
			if(_MenuName.equals(getString(R.string.appGridTextCategoryManage)))
			{
				openActivity(ActivityCategory.class);
				return;
			}
			if(_MenuName.equals(getString(R.string.appGridTextPayoutAdd)))
			{
				openActivity(ActivityPayoutAddOrEdit.class);
				return;
			}
			if(_MenuName.equals(getString(R.string.appGridTextPayoutManage)))
			{
				openActivity(ActivityPayout.class);
				return;
			}
/*			if(_MenuName.equals(getString(R.string.appGridTextStatisticsManage)))
			{
				OpenActivity(ActivityStatistics.class);
				return;
			}*/
		}
	}
}